package com.lwi.log;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.lwi.log.icons.Icons;
import com.lwi.log.panel.LogPanel;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * 实现标签窗口
 *
 * @author Administrator
 */
public class LogWindow implements ToolWindowFactory {
    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        LogPanel panel = new LogPanel();
        JComponent component = panel.getConsolePanel(project);
        ContentFactory factory = ContentFactory.SERVICE.getInstance();
        Content content = factory.createContent(component, "", false);
        toolWindow.setIcon(Icons.MyBatisIcon);
        toolWindow.getContentManager().addContent(content);
    }
}
